<?php
//This function checks username and password
function validateUser($name, $pword){

    $fh = fopen('members.txt', 'r');

    //Loop thru the file and get a line
    while($line = fgets($fh)) {
    //process the line that has just been read
    //convert the line string into an array, using "|" as the delimiter
    $lineArray = explode(",", $line);
    //put each element of the array into another variable
    //and process username and password
    $username = trim($lineArray[0]);
    $password = trim($lineArray[1]);

        if(($name == $username) && ($pword == $password)){
        //username & password verified
        return TRUE;
        }
    }

fclose($fh);
}
//This function appends details to a file
function appendToFile($textFileName,$toBeAdded){

      $fh = fopen("$textFileName","a");
      fwrite($fh,$toBeAdded);
      fclose($fh);
}


?>